﻿using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Data.SqlClient;

using System.Text;
using com.vs.DataAccess.DO;
using com.vs.General;

namespace com.vs.DataAccess.DO
{
    public partial class ShippingContainerDO
    {

        #region "Get Model"
        /// <summary>
        /// 将符合数据库主键的持久对象提取到模型对象中，如数据库符合条件的持久对象不存在，则返回空对象
        /// </summary>
        /// <remarks></remarks>
        public static ShippingContainerDO GetModelByPK(Session sess, int iIntRecContNum)
        {
            DataHelper helper = null;
            DataTable dtModel = null;
            string stSQL = SelectSequel + " WHERE INTERNAL_CONTAINER_NUM = @INTERNAL_CONTAINER_NUM ";

            try
            {
                helper = new DataHelper(sess);
                dtModel = helper.GetTable(CommandType.Text, stSQL, new IDataParameter[]{
                    DataHelper.BuildParameter(sess, "@INTERNAL_CONTAINER_NUM", iIntRecContNum)
                });
                if (!DataManager.IsEmpty(dtModel))
                {
                    return GetModel(dtModel.Rows[0]);
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                ExceptionManager.LogException(sess, e);
                return null;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

        #endregion

        #region "DataBase Operation"
        /// <summary>
        /// 在数据库里创建该数据访问对象的持久化数据，同时自增长属性INTERNAL_CONTAINER_NUM也会同时得到更新,并提供数据库事务支持
        /// </summary>
        /// <remarks></remarks>
        public string Insert(Session sess)
        {
            DataHelper helper = null;
            IDataParameter[] paras = null;
            string stSQL = "SHP_IShippingContainer";

            try
            {
                helper = new DataHelper(sess);
                paras = ValueParas(this);
                return "" + helper.GetInt(CommandType.StoredProcedure, stSQL, paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

        public string Delete(Session sess)
        {
            DataHelper helper = null;
            string stSQL = "DELETE FROM SHIPPING_CONTAINER WHERE INTERNAL_CONTAINER_NUM = @INTERNAL_CONTAINER_NUM";
            try
            {
                helper = new DataHelper(sess);
                helper.Update(CommandType.Text, stSQL, UpdateWherePara(this));
                return null;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

        /// <summary>
        /// 将该数据访问对象的变化同步到数据库中，如果该数据访问对象在数据库中的持久数据不存在，同步不会发生，同时也不会抛出例外
        /// </summary>
        /// <remarks></remarks>
        public string Update(Session sess)
        {
            DataHelper helper = null;
            string stSQL = "SHP_UShippingContainer";
            try
            {
                helper = new DataHelper(sess);
                helper.Update(CommandType.StoredProcedure, stSQL, ValueParas(this));
                return null;
            }
            catch (Exception e)
            {
                ExceptionManager.LogException(sess, e);
                return e.Message;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

        public string Update(Session sess, Dictionary<string, object> dcData)
        {
            DataHelper helper = null;
            StringBuilder sbSQL = null;
            string stSQL = null;
            int i = 0;
            IDataParameter[] paras = null;

            try
            {
                if (dcData.Count < 1)
                    return null;
                helper = new DataHelper(sess);
                sbSQL = new StringBuilder(256)
                            .Append(" UPDATE SHIPMENT_CONTAINER SET ");
                paras = new IDataParameter[dcData.Count + 1];
                foreach (KeyValuePair<string, object> kvp in dcData)
                {
                    sbSQL.Append(kvp.Key).Append(" = @Value").Append(i).Append(",");
                    paras[i] = new SqlParameter("@Value" + i, kvp.Value);
                    i++;
                }

                stSQL = sbSQL.ToString();
                stSQL = stSQL.Substring(0, stSQL.Length - 1);

                stSQL = stSQL + " WHERE INTERNAL_CONTAINER_NUM = @INTERNAL_CONTAINER_NUM";
                paras[i] = new SqlParameter("@INTERNAL_CONTAINER_NUM", this.INTERNAL_CONTAINER_NUM);

                helper.Update(CommandType.Text, stSQL, paras);

                return null;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }
        #endregion

        #region "Data Load"
        /// <summary>
        /// 装载对象RECEIPCONTAINER的所有持久性对象到集合，如果数据量大，调用此方法会造成性能上的问题，请谨慎使用
        /// </summary>
        /// <remarks></remarks>
        public static List<ShippingContainerDO> GetAll(Session sess)
        {
            DataHelper helper = null;
            DataTable dtModel = null;

            try
            {
                helper = new DataHelper(sess);
                dtModel = helper.GetTable(CommandType.Text, SelectSequel);
                return LoadListFromDataView(dtModel.DefaultView);
            }
            catch (Exception e)
            {
                ExceptionManager.LogException(sess, e);
                return null;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

        /// <summary>
        /// 装载指定列的值等于指定值的的所有持久性RECEIPCONTAINER对象到集合
        /// </summary>
        /// <remarks></remarks>
        /// 
        public static DataTable GetTableByColumn(Session sess, string columnName, Object value)
        {
            DataHelper helper = null;
            IDataParameter[] paras = null;
            string stSQL = null;
            try
            {
                helper = new DataHelper(sess);
                stSQL = SelectSequel + " Where [" + columnName + "] =@Value ";
                paras = new IDataParameter[]{
                                new SqlParameter( "@Value", value)
                            };
                return helper.GetTable(CommandType.Text, stSQL, paras);
            }
            catch (Exception e)
            {
                ExceptionManager.LogException(sess, e);
                return null;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

        public static List<ShippingContainerDO> GetListByColumn(Session sess, string columnName, Object value)
        {
            DataTable dtModel = null;

            try
            {
                dtModel = GetTableByColumn(sess, columnName, value);
                return LoadListFromDataView(dtModel.DefaultView);
            }
            catch (Exception e)
            {
                ExceptionManager.LogException(sess, e);
                return null;
            }
            finally
            {
            }
        }

        /// <summary>
        /// 从DataView装载持久性RECEIPCONTAINER对象到集合
        /// </summary>
        /// <remarks></remarks>
        private static List<ShippingContainerDO> LoadListFromDataView(DataView dv)
        {
            List<ShippingContainerDO> list = new List<ShippingContainerDO>();
            for (int index = 0; index <= dv.Count - 1; index++)
            {
                list.Add(GetModel(dv[index].Row));
            }
            return list;
        }


        /// <summary>
        /// loading data value  to property from Datarow
        /// </summary>
        /// <remarks></remarks>
        private static ShippingContainerDO GetModel(DataRow row)
        {
            ShippingContainerDO obj = new ShippingContainerDO();
            if (!row["INTERNAL_CONTAINER_NUM"].Equals(DBNull.Value)) obj.INTERNAL_CONTAINER_NUM = Convert.ToInt32(row["INTERNAL_CONTAINER_NUM"]);
            if (!row["CONTAINER_ID"].Equals(DBNull.Value)) obj.CONTAINER_ID = Convert.ToString(row["CONTAINER_ID"]);
            if (!row["WAREHOUSE"].Equals(DBNull.Value)) obj.WAREHOUSE = Convert.ToString(row["WAREHOUSE"]);
            if (!row["CONTAINER_TYPE"].Equals(DBNull.Value)) obj.CONTAINER_TYPE = Convert.ToString(row["CONTAINER_TYPE"]);
            if (!row["CONTAINER_CLASS"].Equals(DBNull.Value)) obj.CONTAINER_CLASS = Convert.ToString(row["CONTAINER_CLASS"]);
            if (!row["STATUS"].Equals(DBNull.Value)) obj.STATUS = Convert.ToInt32(row["STATUS"]);
            if (!row["PARENT"].Equals(DBNull.Value)) obj.PARENT = Convert.ToInt32(row["PARENT"]);
            if (!row["WEIGHT"].Equals(DBNull.Value)) obj.WEIGHT = Convert.ToDouble(row["WEIGHT"]);
            if (!row["WEIGHT_UM"].Equals(DBNull.Value)) obj.WEIGHT_UM = Convert.ToString(row["WEIGHT_UM"]);
            if (!row["VOLUME"].Equals(DBNull.Value)) obj.VOLUME = Convert.ToDouble(row["VOLUME"]);
            if (!row["LENGTH"].Equals(DBNull.Value)) obj.LENGTH = Convert.ToDouble(row["LENGTH"]);
            if (!row["WIDTH"].Equals(DBNull.Value)) obj.WIDTH = Convert.ToDouble(row["WIDTH"]);
            if (!row["HEIGHT"].Equals(DBNull.Value)) obj.HEIGHT = Convert.ToDouble(row["HEIGHT"]);
            if (!row["DIMENSION_UM"].Equals(DBNull.Value)) obj.DIMENSION_UM = Convert.ToString(row["DIMENSION_UM"]);
            if (!row["VOLUME_UM"].Equals(DBNull.Value)) obj.VOLUME_UM = Convert.ToString(row["VOLUME_UM"]);
            if (!row["VALUE"].Equals(DBNull.Value)) obj.VALUE = Convert.ToDouble(row["VALUE"]);
            if (!row["INTERNAL_SHIPMENT_NUM"].Equals(DBNull.Value)) obj.INTERNAL_SHIPMENT_NUM = Convert.ToInt32(row["INTERNAL_SHIPMENT_NUM"]);
            if (!row["INTERNAL_SHIPMENT_LINE_NUM"].Equals(DBNull.Value)) obj.INTERNAL_SHIPMENT_LINE_NUM = Convert.ToInt32(row["INTERNAL_SHIPMENT_LINE_NUM"]);
            if (!row["COMPANY"].Equals(DBNull.Value)) obj.COMPANY = Convert.ToString(row["COMPANY"]);
            if (!row["ITEM"].Equals(DBNull.Value)) obj.ITEM = Convert.ToString(row["ITEM"]);
            if (!row["QUANTITY"].Equals(DBNull.Value)) obj.QUANTITY = Convert.ToInt32(row["QUANTITY"]);
            if (!row["QUANTITY_UM"].Equals(DBNull.Value)) obj.QUANTITY_UM = Convert.ToString(row["QUANTITY_UM"]);
            if (!row["TRACKING_NUMBER"].Equals(DBNull.Value)) obj.TRACKING_NUMBER = Convert.ToString(row["TRACKING_NUMBER"]);
            if (!row["USER_DEF1"].Equals(DBNull.Value)) obj.USER_DEF1 = Convert.ToString(row["USER_DEF1"]);
            if (!row["USER_DEF2"].Equals(DBNull.Value)) obj.USER_DEF2 = Convert.ToString(row["USER_DEF2"]);
            if (!row["USER_DEF3"].Equals(DBNull.Value)) obj.USER_DEF3 = Convert.ToString(row["USER_DEF3"]);
            if (!row["USER_DEF4"].Equals(DBNull.Value)) obj.USER_DEF4 = Convert.ToString(row["USER_DEF4"]);
            if (!row["USER_DEF5"].Equals(DBNull.Value)) obj.USER_DEF5 = Convert.ToString(row["USER_DEF5"]);
            if (!row["USER_DEF6"].Equals(DBNull.Value)) obj.USER_DEF6 = Convert.ToString(row["USER_DEF6"]);
            if (!row["USER_DEF7"].Equals(DBNull.Value)) obj.USER_DEF7 = Convert.ToDouble(row["USER_DEF7"]);
            if (!row["USER_DEF8"].Equals(DBNull.Value)) obj.USER_DEF8 = Convert.ToDouble(row["USER_DEF8"]);
            if (!row["USER_STAMP"].Equals(DBNull.Value)) obj.USER_STAMP = Convert.ToString(row["USER_STAMP"]);
            if (!row["DATE_TIME_STAMP"].Equals(DBNull.Value)) obj.DATE_TIME_STAMP = Convert.ToDateTime(row["DATE_TIME_STAMP"]);
            if (!row["GROUP_POSITION"].Equals(DBNull.Value)) obj.GROUP_POSITION = Convert.ToInt32(row["GROUP_POSITION"]);
            if (!row["INTERNAL_WAVE_NUM"].Equals(DBNull.Value)) obj.INTERNAL_WAVE_NUM = Convert.ToInt32(row["INTERNAL_WAVE_NUM"]);
            if (!row["CONTAINER_COUNT_NUMBER"].Equals(DBNull.Value)) obj.CONTAINER_COUNT_NUMBER = Convert.ToInt32(row["CONTAINER_COUNT_NUMBER"]);
            if (!row["CONTAINER_COUNT_TOTAL"].Equals(DBNull.Value)) obj.CONTAINER_COUNT_TOTAL = Convert.ToInt32(row["CONTAINER_COUNT_TOTAL"]);
            if (!row["GROUP_NUM"].Equals(DBNull.Value)) obj.GROUP_NUM = Convert.ToInt32(row["GROUP_NUM"]);
            if (!row["PARENT_CONTAINER_ID"].Equals(DBNull.Value)) obj.PARENT_CONTAINER_ID = Convert.ToString(row["PARENT_CONTAINER_ID"]);
            if (!row["INTERNAL_SHIP_ALLOC_NUM"].Equals(DBNull.Value)) obj.INTERNAL_SHIP_ALLOC_NUM = Convert.ToInt32(row["INTERNAL_SHIP_ALLOC_NUM"]);
            if (!row["TASK_CREATED"].Equals(DBNull.Value)) obj.TASK_CREATED = Convert.ToString(row["TASK_CREATED"]);
            if (!row["ATTRIBUTE_NUM"].Equals(DBNull.Value)) obj.ATTRIBUTE_NUM = Convert.ToInt32(row["ATTRIBUTE_NUM"]);
            if (!row["ORIGINAL_PICK_LOC"].Equals(DBNull.Value)) obj.ORIGINAL_PICK_LOC = Convert.ToString(row["ORIGINAL_PICK_LOC"]);
            if (!row["ATTRIBUTE1"].Equals(DBNull.Value)) obj.ATTRIBUTE1 = Convert.ToString(row["ATTRIBUTE1"]);
            if (!row["ATTRIBUTE2"].Equals(DBNull.Value)) obj.ATTRIBUTE2 = Convert.ToString(row["ATTRIBUTE2"]);
            if (!row["ATTRIBUTE3"].Equals(DBNull.Value)) obj.ATTRIBUTE3 = Convert.ToString(row["ATTRIBUTE3"]);
            if (!row["ATTRIBUTE4"].Equals(DBNull.Value)) obj.ATTRIBUTE4 = Convert.ToString(row["ATTRIBUTE4"]);
            if (!row["ATTRIBUTE5"].Equals(DBNull.Value)) obj.ATTRIBUTE5 = Convert.ToString(row["ATTRIBUTE5"]);
            if (!row["ATTRIBUTE6"].Equals(DBNull.Value)) obj.ATTRIBUTE6 = Convert.ToString(row["ATTRIBUTE6"]);
            if (!row["ATTRIBUTE7"].Equals(DBNull.Value)) obj.ATTRIBUTE7 = Convert.ToString(row["ATTRIBUTE7"]);
            if (!row["ATTRIBUTE8"].Equals(DBNull.Value)) obj.ATTRIBUTE8 = Convert.ToString(row["ATTRIBUTE8"]);


            return obj;
        }

        #endregion

        #region "Other function"
        /// <summary>
        /// 该数据访问对象从数据库中提取数据的Sql语句 
        /// </summary>
        /// <remarks></remarks>
        private static string SelectSequel
        {
            get
            {
                return "Select * From [SHIPPING_CONTAINER] ";
            }
        }

        /// <summary>
        /// 该数据访问对象的属性值装载到数据库更新参数数组
        /// </summary>
        /// <remarks></remarks>
        private static IDataParameter[] ValueParas(ShippingContainerDO obj)
        {
            SqlParameter[] paras = new SqlParameter[51];
            paras[0] = new SqlParameter("@INTERNAL_CONTAINER_NUM", obj.INTERNAL_CONTAINER_NUM);
            paras[0].DbType = DbType.String;
            paras[1] = new SqlParameter("@CONTAINER_ID", obj.CONTAINER_ID == String.Empty ? DBNull.Value : (object)obj.CONTAINER_ID);
            paras[1].DbType = DbType.String;
            paras[2] = new SqlParameter("@WAREHOUSE", obj.WAREHOUSE == String.Empty ? DBNull.Value : (object)obj.WAREHOUSE);
            paras[2].DbType = DbType.String;
            paras[3] = new SqlParameter("@CONTAINER_TYPE", obj.CONTAINER_TYPE == String.Empty ? DBNull.Value : (object)obj.CONTAINER_TYPE);
            paras[3].DbType = DbType.String;
            paras[4] = new SqlParameter("@CONTAINER_CLASS", obj.CONTAINER_CLASS == String.Empty ? DBNull.Value : (object)obj.CONTAINER_CLASS);
            paras[4].DbType = DbType.String;
            paras[5] = new SqlParameter("@STATUS", obj.STATUS);
            paras[5].DbType = DbType.Int32;
            paras[6] = new SqlParameter("@PARENT", obj.PARENT);
            paras[6].DbType = DbType.Double;
            paras[7] = new SqlParameter("@WEIGHT", obj.WEIGHT);
            paras[7].DbType = DbType.Double;
            paras[8] = new SqlParameter("@WEIGHT_UM", obj.WEIGHT_UM == String.Empty ? DBNull.Value : (object)obj.WEIGHT_UM);
            paras[8].DbType = DbType.String;
            paras[9] = new SqlParameter("@VOLUME", obj.VOLUME);
            paras[9].DbType = DbType.Double;
            paras[10] = new SqlParameter("@LENGTH", obj.LENGTH );
            paras[10].DbType = DbType.Double;
            paras[11] = new SqlParameter("@WIDTH", obj.WIDTH );
            paras[11].DbType = DbType.Double;
            paras[12] = new SqlParameter("@HEIGHT", obj.HEIGHT);
            paras[12].DbType = DbType.Double;
            paras[13] = new SqlParameter("@DIMENSION_UM", obj.DIMENSION_UM == String.Empty ? DBNull.Value : (object)obj.DIMENSION_UM);
            paras[13].DbType = DbType.String;
            paras[14] = new SqlParameter("@VOLUME_UM", obj.VOLUME_UM == String.Empty ? DBNull.Value : (object)obj.VOLUME_UM);
            paras[14].DbType = DbType.String;
            paras[15] = new SqlParameter("@VALUE", obj.VALUE);
            paras[15].DbType = DbType.Double;
            paras[16] = new SqlParameter("@INTERNAL_SHIPMENT_NUM", obj.INTERNAL_SHIPMENT_NUM);
            paras[16].DbType = DbType.String;
            paras[17] = new SqlParameter("@INTERNAL_SHIPMENT_LINE_NUM", obj.INTERNAL_SHIPMENT_LINE_NUM);
            paras[17].DbType = DbType.String;
            paras[18] = new SqlParameter("@COMPANY", obj.COMPANY == String.Empty ? DBNull.Value : (object)obj.COMPANY);
            paras[18].DbType = DbType.String;
            paras[19] = new SqlParameter("@ITEM", obj.ITEM == String.Empty ? DBNull.Value : (object)obj.ITEM);
            paras[19].DbType = DbType.String;
            paras[20] = new SqlParameter("@QUANTITY", obj.QUANTITY);
            paras[20].DbType = DbType.Int32;
            paras[21] = new SqlParameter("@QUANTITY_UM", obj.QUANTITY_UM == String.Empty ? DBNull.Value : (object)obj.QUANTITY_UM);
            paras[21].DbType = DbType.String;
            paras[22] = new SqlParameter("@TRACKING_NUMBER", obj.TRACKING_NUMBER == String.Empty ? DBNull.Value : (object)obj.TRACKING_NUMBER);
            paras[22].DbType = DbType.String;
            paras[23] = new SqlParameter("@USER_DEF1", obj.USER_DEF1 == String.Empty ? DBNull.Value : (object)obj.USER_DEF1);
            paras[23].DbType = DbType.String;
            paras[24] = new SqlParameter("@USER_DEF2", obj.USER_DEF2 == String.Empty ? DBNull.Value : (object)obj.USER_DEF2);
            paras[24].DbType = DbType.String;
            paras[25] = new SqlParameter("@USER_DEF3", obj.USER_DEF3 == String.Empty ? DBNull.Value : (object)obj.USER_DEF3);
            paras[25].DbType = DbType.String;
            paras[26] = new SqlParameter("@USER_DEF4", obj.USER_DEF4 == String.Empty ? DBNull.Value : (object)obj.USER_DEF4);
            paras[26].DbType = DbType.String;
            paras[27] = new SqlParameter("@USER_DEF5", obj.USER_DEF5 == String.Empty ? DBNull.Value : (object)obj.USER_DEF5);
            paras[27].DbType = DbType.String;
            paras[28] = new SqlParameter("@USER_DEF6", obj.USER_DEF6 == String.Empty ? DBNull.Value : (object)obj.USER_DEF6);
            paras[28].DbType = DbType.String;
            paras[29] = new SqlParameter("@USER_DEF7", obj.USER_DEF7);
            paras[29].DbType = DbType.Double;
            paras[30] = new SqlParameter("@USER_DEF8", obj.USER_DEF8);
            paras[30].DbType = DbType.Double;
            paras[31] = new SqlParameter("@USER_STAMP", obj.USER_STAMP == String.Empty ? DBNull.Value : (object)obj.USER_STAMP);
            paras[31].DbType = DbType.String;
            paras[32] = new SqlParameter("@DATE_TIME_STAMP", System.DateTime.Now);
            paras[32].DbType = DbType.DateTime;
            paras[33] = new SqlParameter("@GROUP_POSITION", obj.GROUP_POSITION);
            paras[33].DbType = DbType.Int32;
            paras[34] = new SqlParameter("@INTERNAL_WAVE_NUM", obj.INTERNAL_WAVE_NUM);
            paras[34].DbType = DbType.Int32;
            paras[35] = new SqlParameter("@CONTAINER_COUNT_NUMBER", obj.CONTAINER_COUNT_NUMBER);
            paras[35].DbType = DbType.Int32;
            paras[36] = new SqlParameter("@CONTAINER_COUNT_TOTAL", obj.CONTAINER_COUNT_TOTAL);
            paras[36].DbType = DbType.Int32;
            paras[37] = new SqlParameter("@GROUP_NUM", obj.GROUP_NUM);
            paras[37].DbType = DbType.Int32;
            paras[38] = new SqlParameter("@PARENT_CONTAINER_ID", obj.PARENT_CONTAINER_ID == String.Empty ? DBNull.Value : (object)obj.PARENT_CONTAINER_ID);
            paras[38].DbType = DbType.String;
            paras[39] = new SqlParameter("@INTERNAL_SHIP_ALLOC_NUM", obj.INTERNAL_SHIP_ALLOC_NUM);
            paras[39].DbType = DbType.Int32;
            paras[40] = new SqlParameter("@TASK_CREATED", obj.TASK_CREATED == String.Empty ? DBNull.Value : (object)obj.TASK_CREATED);
            paras[40].DbType = DbType.String;
            paras[41] = new SqlParameter("@ATTRIBUTE_NUM", obj.ATTRIBUTE_NUM);
            paras[41].DbType = DbType.Int32;
            paras[42] = new SqlParameter("@ORIGINAL_PICK_LOC", obj.ORIGINAL_PICK_LOC == String.Empty ? DBNull.Value : (object)obj.ORIGINAL_PICK_LOC);
            paras[42].DbType = DbType.String;
            paras[43] = new SqlParameter("@ATTRIBUTE1", obj.ATTRIBUTE1 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE1);
            paras[43].DbType = DbType.String;
            paras[44] = new SqlParameter("@ATTRIBUTE2", obj.ATTRIBUTE2 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE2);
            paras[44].DbType = DbType.String;
            paras[45] = new SqlParameter("@ATTRIBUTE3", obj.ATTRIBUTE3 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE3);
            paras[45].DbType = DbType.String;
            paras[46] = new SqlParameter("@ATTRIBUTE4", obj.ATTRIBUTE4 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE4);
            paras[46].DbType = DbType.String;
            paras[47] = new SqlParameter("@ATTRIBUTE5", obj.ATTRIBUTE5 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE5);
            paras[47].DbType = DbType.String;
            paras[48] = new SqlParameter("@ATTRIBUTE6", obj.ATTRIBUTE6 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE6);
            paras[48].DbType = DbType.String;
            paras[49] = new SqlParameter("@ATTRIBUTE7", obj.ATTRIBUTE7 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE7);
            paras[49].DbType = DbType.String;
            paras[50] = new SqlParameter("@ATTRIBUTE8", obj.ATTRIBUTE8 == String.Empty ? DBNull.Value : (object)obj.ATTRIBUTE8);
            paras[50].DbType = DbType.String;

            return paras;
        }

        private static IDataParameter[] UpdateWherePara(ShippingContainerDO recContDO)
        {
            SqlParameter[] paras = new SqlParameter[1];
            paras[0] = new SqlParameter("@INTERNAL_CONTAINER_NUM", recContDO.INTERNAL_CONTAINER_NUM);
            return paras;
        }

        #endregion

        public static List<ShippingContainerDO> GetListByColumns(Session sess, List<KeyValuePair<string, KeyValuePair<string, object>>> dcParam, string stOrderBy)
        {
            DataTable dtModel = null;

            try
            {
                dtModel = GetTableByColumns(sess, dcParam, stOrderBy);
                return LoadListFromDataView(dtModel.DefaultView);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
            }
        }

        public static DataTable GetTableByColumns(Session sess, List<KeyValuePair<string, KeyValuePair<string, object>>> dcParam, string stOrderBy)
        {
            DataHelper helper = null;
            StringBuilder sbSQL = null;
            int i = 0;
            IDataParameter[] pars = null;

            try
            {
                helper = new DataHelper(sess);
                sbSQL = new StringBuilder(SelectSequel)
                    .Append(" WHERE 1=1 ");

                pars = new IDataParameter[dcParam.Count];
                foreach (KeyValuePair<string, KeyValuePair<string, object>> de in dcParam)
                {
                    sbSQL.Append(" AND ").Append(de.Key).Append(de.Value.Key).Append("@Value").Append(i);
                    pars[i] = new SqlParameter("@Value" + i, de.Value.Value);
                    i++;
                }

                if (!StringManager.IsEmpty(stOrderBy))
                {
                    sbSQL.Append(stOrderBy);
                }
                return helper.GetTable(CommandType.Text, sbSQL.ToString(), pars);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (helper != null)
                    helper.Dispose();
            }
        }

    }
}
